﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using JCNT.DAL;

namespace JCNT.NoteWeb
{
    public partial class Login : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Btn_OK.Attributes.Add("onmousemove", "this.className='button_in'");
                //Btn_OK.Attributes.Add("onmouseout", "this.className='button_out'");
                //Btn_Cancel.Attributes.Add("onmousemove", "this.className='button_in'");
                //Btn_Cancel.Attributes.Add("onmouseout", "this.className='button_out'");
            }
            //TBox_Pas.Text = "li0544";
            //TBox_Use.Text = "li0544";
        }

        protected void Btn_OK_Click(object sender, EventArgs e)
        {

            //TBox_Pas.Text = "";
            //TBox_Use.Text = "";
            //Session.Add("login", 1);
            //Session.Timeout = 60;
            //Response.Redirect("default.aspx", true);

            //return;

            string s_use = TBox_Use.Text;
            string s_pas = TBox_Pas.Text;

            if (s_use == "" || s_pas == "")
            {
                //Response.Write("<script>alert('用户名和密码不能为空！');</script>");
                lab_info.Text = "用户名和密码不能为空！";
            }
            else
            {
                CUser cuser = new CUser();
                if (cuser.chkLogin(s_use, s_pas))
                {
                    TBox_Pas.Text = "";
                    TBox_Use.Text = "";
                    //Session.Add("login", 1);
                    Session["login"] = s_use;
                    Session.Timeout = 60;
                    Response.Redirect("default.aspx", true);
                }
                else
                {
                    lab_info.Text = "用户名或密码错误！";
                }

            }

        }

        protected void Btn_Cancel_Click(object sender, EventArgs e)
        {
            TBox_Pas.Text = "";
            TBox_Use.Text = "";
            Response.Write("<script>javascript:window.close();</script>");
        }
    }
}
